# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=cl-global-vars
_pkgname="${pkgname#cl-}"
pkgver=1.0.0.r2.gc749f32
pkgrel=2
pkgdesc='Define efficient global variables in Common Lisp'
arch=('any')
url='https://github.com/lmj/global-vars'
license=('MIT')
depends=('common-lisp' 'cl-asdf')
makedepends=('git')
checkdepends=('sbcl')
_commit='c749f32c9b606a1457daa47d59630708ac0c266e'
source=(
  "$pkgname::git+$url#commit=$_commit"
  'run-tests.lisp'
)
b2sums=('SKIP'
        '784af4daa68e0343cc0674adadd544bf806476810a50b316923bd49f6bdc97a2c309812d40404904c69351d8c1f395b4d3d1089f834f3ade7e4a8abdf8fba220')

pkgver() {
  cd "$pkgname"

  # first known commit to receive latest version
  local _pkgver='1.0.0'
  local _pkgcommit='cdb24d3cc7128f23af8f80d0b4e0dbc9c2d9a625'

  git tag "$_pkgver" "$_pkgcommit"

  git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
}

prepare() {
  cd "$pkgname"

  # extract license
  sed -n '/;;; Copyright/,/;;; DEALINGS/p' global-vars.lisp | sed -e 's/^;; //g' > LICENSE
}

check() {
  cd "$pkgname"

  sbcl --script ../run-tests.lisp
}

package() {
  cd "$pkgname"

  # library
  install -vDm644 -t "$pkgdir/usr/share/common-lisp/source/$_pkgname" ./*.{lisp,asd}

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
